import { defineStore } from 'pinia'

export default defineStore('task', {
    state: ()=> ({
        taskIndex: 0, //当前进行到第几个任务
        taskList: [
            {id: 'desc1', src: '', type: 'first-desc'},

            {id: 'desc2', src: '', type: 'lx-desc'},
            {id: 'lx-1', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/LX-1.jpg', type: '罗夏墨迹', index: 1},
            {id: 'lx-2', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/LX-2.jpg', type: '罗夏墨迹', index: 2},
            {id: 'lx-3', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/LX-3.jpg', type: '罗夏墨迹', index: 3},
            {id: 'lx-4', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/LX-4.jpg', type: '罗夏墨迹', index: 4},
            {id: 'lx-5', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/LX-5.jpg', type: '罗夏墨迹', index: 5},

            {id: 'desc3', src: '', type: 'tat-desc'},
            {id: 'tat-1', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/TAT-01.jpg', type: 'tat', index: 1},
            {id: 'tat-2', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/TAT-02.jpg', type: 'tat', index: 2},
            {id: 'tat-3', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/TAT-03.jpg', type: 'tat', index: 3},
            {id: 'tat-4', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/TAT-04.jpg', type: 'tat', index: 4},
            {id: 'tat-5', src: 'https://duomotai-1302957431.cos.ap-chongqing.myqcloud.com/image/TAT-05.jpg', type: 'tat', index: 5},

            {id: 'desc4', src: '', type: 'video-desc'},
            {id: 'video-1', src: 'https://1500040063.vod-qcloud.com/cbd34a5cvodsh1500040063/3b5d10e65145403691970354825/QIm0mZIqcv8A.mp4', type: '观影', index: 1},
            {id: 'video-2', src: 'https://1500040063.vod-qcloud.com/6cdfd395vodcq1500040063/0a9cd1cd5145403691969611846/epKd3ykgOfAA.mp4', type: '观影', index: 2},
            {id: 'video-3', src: 'https://1500040063.vod-qcloud.com/cbd34a5cvodsh1500040063/36f8f4cc5145403691970190959/upJOW7bcGNEA.mp4', type: '观影', index: 3},
            {id: 'interview-1', src: '', type: '访谈', index: 1},
        ]
    }),
    getters: {
        // 根据taskList.length 和taskIndex 计算当前任务进度百分比
        taskProgress: (state) => {
            if (state.taskList.length === 0) return 0;
            return Math.round((state.taskIndex / state.taskList.length) * 100);
        }
    },
    actions: {

    },
    persist: {
        key: 'task',
        storage: window.localStorage,
    }
})